package com.springinaction.springaop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AdviceName;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Audience {
	

//	@Pointcut("execution(* com.springinaction.springaop.Performance.perform(..))")单个方法
	@Pointcut("execution(* com.springinaction.springaop.Performance.*(..))")//所有方法
	public void performance(){
		
	}

	@Before("performance()")
	public void beforeFirst(){
		System.out.println("beforeFirst");
	}
	
	@Around("performance()")
	public void aroundAdvice(ProceedingJoinPoint joinPoint){
		System.out.println("aroundAdvice");
		try {
			joinPoint.proceed();
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("proceed()");
	}
	
	@Pointcut("execution(* com.springinaction.springaop.Encoreable.performEncore(..))")
	public void performEncore(){
		
	}
	
	@Before("performEncore()")
	public void beforsPerformEncore(){
		System.out.println("beforsPerformEncore");
	}
	
}

